package com.mango.leet.code.week2.game126;

/**
 * https://leetcode.cn/contest/biweekly-contest-126/problems/find-the-sum-of-encrypted-integers/
 *
 * @Author: mango
 * @Date: 2024/3/16 22:37
 */
public class LC100262 {
    public int sumOfEncryptedInt(int[] nums) {
        int result = 0;
        for (int i = 0; i < nums.length; i++) {
            int num = nums[i];
            String numStr = String.valueOf(num);
            int max = 0;
            for (int j = 0; j < numStr.length(); j++) {
                max = Math.max(max, Integer.valueOf(numStr.charAt(j)+""));
            }
            String maxStr = "";
            for (int j = 0; j < numStr.length(); j++) {
                maxStr += max;
            }
            result += Integer.valueOf(maxStr);
        }
        return result;
    }

    public static void main(String[] args) {
        int[] nums = {1,21,3};
        LC100262 s = new LC100262();
        System.out.println(s.sumOfEncryptedInt(nums));
    }
}
